home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_pyr_proximityglow.cog < prev    next >
Text File  |  1999-11-15  |  6KB  |  256 lines

  1. # Jones 3D Cog Script
  2. #
  3. # pyr_proximityglow.cog
  4. #    
  5. # Draw light beams in the desert as Indy gets closer to the monojackals
  6. #
  7. # [RKD]
  8. #
  9. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  10. # ========================================================================================
  11.  
  12. symbols
  13. message    startup
  14. message    pulse
  15. message entered
  16. message exited
  17. message    user1
  18.  
  19. # world things
  20. thing    player        nolink    local
  21. thing    sparkle        nolink
  22. thing    boxeye        nolink
  23. thing    flame        nolink
  24.  
  25. # beam and endpoint
  26. thing    beam        nolink    local
  27. thing    endbeam        nolink
  28.  
  29. # extra beam and endpoint for pyramid 3
  30. thing    beam2        nolink    local
  31. thing    endbeam2    nolink
  32.  
  33. # sectors
  34. sector    trigger1
  35. sector    trigger2
  36. sector    trigger3
  37. sector    trigger4
  38. sector    trigger5
  39. sector    trigger6
  40. sector    trigger7
  41.                                                             
  42. # materials
  43. material    sparklemat
  44. material    beammat
  45.  
  46. # world surfaces
  47. surface        bigtrigger        nolink
  48. surface        poolsurface        nolink
  49.  
  50. # variables
  51. flex    distance=0        local
  52. flex    distportion=0    local
  53. flex    oldportion=0    local
  54. flex    maxdistance=2.0
  55. flex    sparklesize=1
  56. flex    nullvalue=0.0    local
  57. int        dummy=0            local
  58. int        insector=0        local
  59. int        beamstatus=1
  60. end
  61.  
  62. code
  63. startup:
  64.     sleep(.01);
  65.  
  66.     # make animation run throughout
  67.     nullvalue = AnimateSpriteSize(sparkle, '.5 .5 0.0', '.6 .6 0.0', .1);
  68.     nullvalue = MaterialAnim(sparklemat, 5, 1);
  69.     SetThingFlags(sparkle, 0x10);
  70.  
  71.     # create beam, hide it
  72.     beam = CreatePolylineThing(sparkle, endbeam, '0 0 0', beammat, .02, .02, 0);
  73.     nullvalue = ThingFadeAnim(beam, .1, 0, .01, 0);
  74.     SetThingFlags(beam, 0x10);
  75.     
  76.     # beamstatus key:
  77.     #    0: puzzle solved, no beams
  78.     #    1: only one beam
  79.     #    2: two beams, one of them is on (pyramid 3)
  80.     #    3: two beams, both of them are on (pyramids 1 and 4)
  81.     
  82.     # if two beams exist (for pool puzzle) draw a beam to it as well
  83.     # pyramid 1 also draws the extra beam to prevent multisector beam from blinking out
  84.     # pyramid 4    also draws the extra beam to enhance visibility of yellow glow
  85.         
  86.     if (beamstatus >= 2)
  87.     {
  88.         beam2 = CreatePolylineThing(endbeam, endbeam2, '0 0 0', beammat, .02, .02, 0);
  89.         nullvalue = ThingFadeAnim(beam2, .1, 0, .01, 0);
  90.         SetThingFlags(beam2, 0x10);
  91.     }
  92.     else
  93.     {
  94.         # otherwise ensure that beam2 isn't mistaken for the player
  95.         beam2 = -1;
  96.     }
  97.  
  98.     return;
  99.  
  100. entered:
  101. # --> Trigger sectors
  102.  
  103.     # if already in a trigger sector, or lightbox down, or puzzle solved, exit
  104.     if (insector) return;
  105.     if (GetThingFlags(flame) & 0x10) return;
  106.     if (beamstatus == 0) return;
  107.  
  108.     insector = 1;
  109.     
  110.     # set sparkle light to light value of boxeye
  111.     SetThingLight(sparkle, GetThingLight(boxeye), .001, .1);
  112.     
  113.     # fade the beam in to a light alpha
  114.     ThingFadeAnim(beam, 0, .1, 3, 0);
  115.  
  116.     # if pool surface is visible for pyramid 3 upgrade beamstatus and draw 2nd beam
  117.     if ((GetFaceGeoMode(poolsurface) == 4) && (beamstatus >= 2))
  118.     {
  119.         beamstatus = 3;
  120.         ClearThingFlags(beam2, 0x10);
  121.         ThingFadeAnim(beam2, 0, .1, 3, 0);
  122.     }
  123.         
  124.     sleep(3);
  125.  
  126.     # start proximity pulse
  127.     SetPulse(.2);
  128.     ClearThingFlags(beam, 0x10);
  129.     ClearThingFlags(sparkle, 0x10);
  130.  
  131.     return;
  132.  
  133. exited:
  134. # --> Trigger sectors
  135.  
  136.     # if flame not visible, exit
  137.     if (GetThingFlags(flame) & 0x10) return;
  138.     
  139.     # if puzzle solved, exit
  140.     if (beamstatus == 0) return;
  141.  
  142.     player = GetLocalPlayerThing();
  143.  
  144.     # sleep to prevent "Player in the sector he just exited" bug
  145.     sleep(.01);
  146.     
  147.     # if player entered another trigger sector, exit
  148.     if ((GetThingSector(player) == trigger1) || (GetThingSector(player) == trigger2) ||
  149.         (GetThingSector(player) == trigger3) || (GetThingSector(player) == trigger4) ||
  150.         (GetThingSector(player) == trigger5) || (GetThingSector(player) == trigger6) ||
  151.         (GetThingSector(player) == trigger7)) return;
  152.     
  153.     sleep(.5);
  154.  
  155.     # wierd entry problem on monojackal requires a check
  156.     dummy = GetSenderRef();
  157.     sleep(.1);
  158.     if (GetThingSector(player) == dummy) return;
  159.     
  160.     insector = 0;
  161.     
  162.     # kill pulse and fade the beam out
  163.     SetPulse(0);
  164.     ThingFadeAnim(beam, GetThingAlpha(beam), 0, 3, 0);
  165.  
  166.        # remove 2nd beam if there is one
  167.     if (beamstatus == 3)
  168.     {
  169.         ThingFadeAnim(beam2, GetThingAlpha(beam2), 0, 3, 0);
  170.     }
  171.  
  172.     # reset distportion and make sparkle fully alpha
  173.     distportion = 0;
  174.     AnimateSpriteSize(sparkle, '1 1 0', '1 1 0', 2);
  175.     
  176.     return;
  177.  
  178. user1:
  179. # ---> monojackal cog
  180.     
  181.     SetPulse(0);
  182.     
  183.     AnimateSpriteSize(sparkle, '1 1 0', '1 1 0', 2);
  184.     MaterialAnim(sparklemat, 5, 0);
  185.  
  186.     # fade the main beam out
  187.     ThingFadeAnim(beam, 1, 0, 8, 0);
  188.     
  189.     # fade the secondary beam out, if it exists
  190.     if (beamstatus == 3)
  191.     {
  192.         ThingFadeAnim(beam2, 1, 0, 8, 0);
  193.     }
  194.     
  195.     # wait a bit, then destroy sparkle and other beam
  196.     sleep(9);
  197.     DestroyThing(sparkle);
  198.     DestroyThing(beam);
  199.  
  200.     # fade the other beam out if it exists
  201.     if (beamstatus == 3)
  202.     {
  203.         DestroyThing(beam2);
  204.     }
  205.  
  206.     # set beam status to reflect puzzle completion
  207.     beamstatus == 0;
  208.  
  209.     return;
  210.     
  211. pulse:
  212.     # get distance from player to center of cyclops
  213.     distance = VectorDist(GetThingPos(GetLocalPlayerThing()), GetSurfaceCenter(bigtrigger));
  214.         
  215.     # if distance is within the set parameter, alter sparkle and beam value
  216.     if (distance < maxdistance)
  217.     {
  218.         # calculate relative nearness to monojackal after saving previous calculation
  219.         oldportion = distportion;
  220.         distportion = 1 - (distance/maxdistance);
  221.         
  222.         # fade and resize sparkle with proximity
  223.         nullvalue = AnimateSpriteSize(sparkle, VectorSet(oldportion * sparklesize, oldportion * sparklesize, oldportion * 1.5),
  224.                                     VectorSet(distportion * sparklesize, distportion * sparklesize, distportion * 1.5), .1);
  225.     
  226.         # if no change in distance, exit
  227.         if (oldportion == distportion) return;
  228.         
  229.         # otherwise, fade 1st beam in or out    
  230.         nullvalue = ThingFadeAnim(beam, oldportion, distportion, .2, 0);
  231.         
  232.         # redraw 2nd beam if it exists
  233.         if (beamstatus == 3)
  234.         {
  235.             nullvalue = ThingFadeAnim(beam2, oldportion, distportion, .2, 0);
  236.         }
  237.     }
  238.     else
  239.     {
  240.         # set alpha to minimum
  241.         nullvalue = SetThingAlpha(beam, 0);
  242.  
  243.         # do the same to the 2nd beam if pool is visible
  244.         if (beamstatus == 3)
  245.         {
  246.             nullvalue = SetThingAlpha(beam2, 0);
  247.         }
  248.     }
  249.  
  250.     return;
  251.  
  252. end
  253.  
  254.  
  255.     
  256.